package com.kucunProject.service;

import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;

import com.kucunProject.dao.DBManager;

public class JudgeUser {

	public boolean judge(String name, String password) {

		boolean flag = false;

		ResultSet rs = null;
		DBManager man = new DBManager();
		PreparedStatement ps = null;
		String sql = "select * from users where name = ?";

		try {
			ps = man.connect().prepareStatement(sql);
			ps.setString(1, name);
			rs = ps.executeQuery();
			if (rs.next()) {
				if (name != null && name.equals(rs.getString("name"))
						&& password != null
						&& password.equals(rs.getString("password"))) {
					flag = true;
				}
			}
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}

		return flag;

	}
}
